<template>
    <div>
<h1>会员类型注册</h1>


<table class="table-bordered" border="1">
    <tr>
<td>会员级别</td>
<td><input type="text" v-model="zc.name" ></td>
    </tr>
    <tr>


<td></td>
<td><input type="button" value="注册" @click="yz"></td>

    </tr>
</table>

    </div>
</template>

<script setup lang="ts">
import {ref  } from "vue";

import axios from "axios";


const zc = ref({

name:""

})


const yz =()=>{

    if(zc.value.name=="")
{
alert('不能为空');
return;
}
axios.post('https://localhost:7268/api/hy/addlist',zc.value)


.then(res=>{

    if(res.data==-1){

alert('该会员等级已被注册');

}
    if(res.data>0){

      alert('注册成功');
      location.href="/hyxx";

    }
    else{

        alert('注册失败');
    }

})
.catch(error=>{

console.log(error);

})

}






</script>



<style scoped>

</style>